#include "CpLog.h"
#include "CpEvent.h"
#include "CpTrack.h"

ClassImp(CpEvent);

//________________________________________________________________________________________________________________
CpEvent::CpEvent(): TObject(),
    fNumberOfTracks(0),
    fTracks("CpTrack",fNumberOfTracks+1)
{
//
// Constructor
//

}

//________________________________________________________________________________________________________________
CpEvent::~CpEvent()
{
//
// Destructor.
//
}

void CpEvent::Clear()
{
  fNumberOfTracks = 0;
  fTracks.Delete();
}

void CpEvent::Print()
{
  CpInfo(Form("Number of Tracks = %d",fNumberOfTracks));

  CpTrack*track;
  for (Long64_t iTrack=0;iTrack<fNumberOfTracks;iTrack++){
    track = (CpTrack*) fTracks.At(iTrack);
    track->Print();
  }
}


void CpEvent::SimulateTracks(Long64_t& numOfTracks)
{
  for (Long64_t iTrack=0;iTrack<numOfTracks;iTrack++) {
    CpInfo(Form("Simulating Track %d",iTrack));
    SimulateOneTrack();
  }
}


CpTrack* CpEvent::AddTrack(const Int_t& id)
{
  return new(fTracks[fNumberOfTracks++]) CpTrack(id);

}


void CpEvent::SimulateOneTrack()
{
  CpTrack *track = new(fTracks[fNumberOfTracks++]) CpTrack();
  track->SimulatePoints();

}

